<?php
//video_rendere.changed
if(!defined('access')) {
echo 'You cannot access this file directly.';
exit();
} 
$file = htmlspecialchars($this->category_title);
$filescape = str_replace(
        array(" "),
        array("&#32;"),
        $file);
$file1 = $this->category_title;
@unlink("/tmp/pre_test.xml");
$this->srt_to_xml($file);
if($this->Jukebox_Size == "2"){
$this->WatcheUpDB(urldecode($file1), "2");
$multifile = pathinfo(urldecode($file1));
@unlink("/tmp/video_list.dat");
$source = $multifile['dirname'];
        $escapedBracketPath = str_replace('[', '\[', $source);
        $escapedBracketPath = str_replace(']', '\]', $escapedBracketPath);
	$escapedBracketPath = str_replace('\[', '[[]', $escapedBracketPath);
	$escapedBracketPath = str_replace('\]', '[]]', $escapedBracketPath);
        foreach (glob($escapedBracketPath . "/*.".$multifile['extension']) as $files) {
            $video_list[] = $files;
        }
        $video_list ? file_put_contents('/tmp/video_list.dat', implode(PHP_EOL, $video_list)) : false;
}
$db = new SQLite3('/usr/local/etc/dvdplayer/Setup', SQLITE3_OPEN_READONLY);
$resume = $db->query("SELECT Value from setupkeyvalue WHERE Key = 'SETUP_RESUME_MODE'")->fetchArray();
if(!$this->read_config('nextplay')){
   $this->db->exec("INSERT OR REPLACE INTO settings (key, value) VALUES ('nextplay', 'yes') ");
   $nextplay = 'yes';
}
else {
    $nextplay = $this->read_config('nextplay');
}
$font_size = ($this->read_config('font_size')) ? $this->read_config('font_size') : "34";
$font_color = ($this->read_config('font_color')) ? $this->read_config('font_color') : "255:255:255";
$font_offset = ($this->read_config('font_offset')) ? $this->read_config('font_offset') : "-3.5";
$font_shadow_color = ($this->read_config('font_shadow_color')) ? $this->read_config('font_shadow_color') : "0:0:0";
$font_type = ($this->read_config('font_type')) ? $this->read_config('font_type') : "/usr/local/bin/Resource/font/arialnarrowbold.ttf";
$req_info = $this->db->query("SELECT * FROM t1 WHERE path = '" . SQLite3::escapeString($file) . "'");
$infos = $req_info->fetchArray();
if (!$infos) {
    $filename = $parts['filename'];
    $movie_title = "Filename: ".$file;
    $movie_year = "";
    $movie_rating = "";
    $movie_genre = "";
} else {
    $filename = $infos['file'];
    $movie_title = "Title: ".$infos['title'];
    $movie_year = $infos['year'];
    $movie_rating = "IMdb rating: ".$infos['rating'];
    $movie_genre = "Genre: ".$infos['genre'];
}
$subfile="/tmp/test.xml";
if (!file_exists($subfile)){
        $subtitle = "Subtitle Not loaded";
} else {
    if (filesize($subfile) == 0){
        $subtitle = "Subtitle error";
    } else {
        $subtitle = "Subtitle Loaded";
    }
}
echo '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">

    <onEnter>
        cancelIdle();
        nextplay = "'.$nextplay.'";
        screensaver = getCurrentSetting("$[SCREEN_SAVER_TIMING]");
        SetScreenSaverStatus("no");
        url = "' . $filescape . '";
        resume = readStringFromFile(url+".resume");
        aspect_ratio=getCurrentSetting("$[ASPECT_RATIO]");
        aspect_ratio1=aspect_ratio;
        transp = "-1:-1:-1";
        fontcol = "'.$font_color.'";
        font_shadow_col = "'.$font_shadow_color.'";
        fontsize = "'.$font_size.'" ;
        fontoffset = "'.$font_offset.'";
        fontn = "3";
        fix = "1";
        if (fontsize &lt; 24) {
        wh=8;
        mt=2;
        }
        else {
        if (fontsize &gt;=24 &amp;&amp; fontsize &lt; 26) {
        wh=8.5;
        mt=2;
        }
        else {
        wh=10.1;
        mt=2.1;
        }
        }
        fontname="'.$font_type.'";
        first_run = "1";
        delay = 0;
        mark_seen = 2;
        show_time = 0;
        pause = 0;
        subt = 0;
        cnt = 0;
        cnt_sub = 0;
        setRefreshTime(100);
        playItemURL(url, 0, "mediaDisplay", "previewWindow");
        loadXMLFile("/tmp/test.xml");
</onEnter>

    <onExit>
        playItemURL(-1, 1);
        setRefreshTime(-1);
        if (aspect_ratio1 != aspect_ratio)
        setAspectRatio(aspect_ratio);
        if(screensaver != "$[OFF]") {
        SetScreenSaverStatus("yes"); }
</onExit>

    <onRefresh>
        stream_progress = getPlaybackStatus();
        buffer_progress = getCachedStreamDataSize(0, 262144);
        play_elapsed = getStringArrayAt(stream_progress, 0);
        play_total = getStringArrayAt(stream_progress, 1);
        play_rest = play_total - play_elapsed;
        play_status = getStringArrayAt(stream_progress, 3);
        if (play_elapsed &gt;= 0) {
        if (play_elapsed &gt; 60 &amp;&amp; mark_seen == 2) {
        writeStringToFile(url+".seen", "seen");
        mark_seen = 1;
        }
        time_j = play_elapsed - (delay);
        start_line = "start_"+time_j;
        end_line = "end_"+time_j;
        linia1_start = getXMLText("subtitrare", start_line);
        linia1_1_start = getXMLText("subtitrare", start_line, 2);
        linie_end = getXMLText("subtitrare", end_line);
        linie1_end = getXMLText("subtitrare", end_line, 2);
        if ( linia1_start != null){
                tline1 = linia1_start;
             if(linia1_1_start != null){
                cnt += 100;
                cnt_sub += 1;
                count = getXMLElementCount("subtitrare", start_line);
                if(cnt_sub &gt;= 2){
                if(cnt_sub &gt; count){
                                    cnt = 0;
                                    cnt_sub = 0;
                                    count = 0;
                                    tline1 = linia1_start; } else {
                if(getXMLText("subtitrare", start_line, cnt_sub) != null){
                tline1 = getXMLText("subtitrare", start_line, cnt_sub); } } }
                            } else { 
                            cnt = 0;
                    cnt_sub = 0;
                    tline1 = linia1_start; }
        }
        if ( linie_end != null &amp;&amp; linia1_1_start == null){
                tline1 = getXMLText("subtitrare", start_line);
            }
        }
        else {
        tline1 = "";
        }
        if (show_time == 1) {
                arg_time = play_elapsed;
		x = Integer(arg_time / 60);
		h = Integer(arg_time / 3600);
		s = arg_time - (x * 60);
		m = x - (h * 60);
		if(h &lt; 10) 
			ret_string = "0" + sprintf("%s:", h);
		else
			ret_string = sprintf("%s:", h);
		if(m &lt; 10)  ret_string += "0";
		ret_string += sprintf("%s:", m);
		if(s &lt; 10)  ret_string += "0";
		ret_string += sprintf("%s", s);
    stream_elapsed = ret_string;
		  arg_time = play_total;
  		x = Integer(arg_time / 60);
  		h = Integer(arg_time / 3600);
  		s = arg_time - (x * 60);
  		m = x - (h * 60);
  		if(h &lt; 10) 
  			ret_string = "0" + sprintf("%s:", h);
  		else
  			ret_string = sprintf("%s:", h);
  		if(m &lt; 10)  ret_string += "0";
  		ret_string += sprintf("%s:", m);
  		if(s &lt; 10)  ret_string += "0";
  		ret_string += sprintf("%s", s);
		  stream_total = ret_string;
        time_k = time_j - play_elapsed;
        info_delay = "Subtitle sync: " + time_k +" sec.";
        info_title = "'.$movie_title.'";
        mov_rating = "'.$movie_rating.'";
        bar_fg = "/usr/local/etc/www/Jukebox/images/seek_bar_fg.jpg";
        bar_bg = "/usr/local/etc/www/Jukebox/images/seek_bar_bg.jpg";
        info_bg = "/usr/local/bin/Resource/image/IMAGE_MOVIE_INFO_BG.png";
        movie_genre = "'.$movie_genre.'";
        if ( subt == 0 ){
        subtitle = "'.$subtitle.'"; }
        else if( subt == 2){
        tline1 = "";
        subtitle = "Subtitle off"; }
        else if( subt == 1){
            subtitle = "Subtitle Loaded"; }
     } else {
     info_delay = "";
     info_title = "";
        bar_fg = "";
        bar_bg = "";
        stream_total = "";
        stream_elapsed = "";
        movie_genre = "";
        mov_rating = "";
        subtitle = "";
        info_bg = "";
     }';
if ($resume['Value'] == '1') {
        echo '
            if(resume != null  &amp;&amp; first_run == "1")
            {
            if(play_elapsed &gt; 1 &amp;&amp; play_status == 2 &amp;&amp; resume &gt; 10 ) {
            rss = "rss_file:///usr/local/etc/www/Jukebox/dynamicPopup.rss";
            confirm = doModalRss(rss, "mediaDisplay", "popupDialog", 0);
            first_run = "0";
            if (confirm == "$[YES]") {
            playAtTime(resume);
            loadXMLFile("/tmp/test.xml");
            redrawDisplay();
            }
            }
            deleteFile(url+".resume");
            }';
        }
       echo '
 updatePlaybackProgress(stream_progress, "mediaDisplay", "infoDisplay");
</onRefresh>

    <mediaDisplay name="threePartsView"
              showDefaultInfo="no"
              showHeader="no"
              sideLeftWidthPC="0"
              sideRightWidthPC="0"
              backgroundColor="-1:-1:-1"
              idleImageXPC="5" idleImageYPC="5" idleImageWidthPC="8" idleImageHeightPC="10"
    >
        <idleImage>image/POPUP_LOADING_01.png</idleImage>
        <idleImage>image/POPUP_LOADING_02.png</idleImage>
        <idleImage>image/POPUP_LOADING_03.png</idleImage>
        <idleImage>image/POPUP_LOADING_04.png</idleImage>
        <idleImage>image/POPUP_LOADING_05.png</idleImage>
        <idleImage>image/POPUP_LOADING_06.png</idleImage>
        <idleImage>image/POPUP_LOADING_07.png</idleImage>
        <idleImage>image/POPUP_LOADING_08.png</idleImage>

        <previewWindow windowColor="-1:-1:-1" offsetXPC="0" widthPC="100" offsetYPC="0" heightPC="100" />
        <popupDialog>
            <mediaDisplay>
                <onEnter>
                    popupHeader = "Resume Video";
                    popupMessageSize = 0;
                    popupOptionSize = 2;
                    popupOptions = pushBackStringArray(popupOptions, "$[YES]");
                    popupOptions = pushBackStringArray(popupOptions, "$[NO]");
                    popupOptionFocusIndex = 1;
                    popupTimeout = 15;
                </onEnter>
            </mediaDisplay>
        </popupDialog>
        <fontcolor>
    <mediaDisplay>
	<onEnter>
		popupHeader = "Choose Subtitle font color";
			popupMessageSize = 0;
			popupMessages = "";
			popupOptionSize = 3;
			popupOptions = pushBackStringArray(popupOptions, "White");
			popupOptions = pushBackStringArray(popupOptions, "Blue");
			popupOptions = pushBackStringArray(popupOptions, "Yellow");
	</onEnter>
</mediaDisplay>
</fontcolor>
<fontshadowcolor>
    <mediaDisplay>
	<onEnter>
		popupHeader = "Choose Subtitle font shadow color";
			popupMessageSize = 0;
			popupMessages = "";
			popupOptionSize = 4;
			popupOptions = pushBackStringArray(popupOptions, "White");
			popupOptions = pushBackStringArray(popupOptions, "Blue");
			popupOptions = pushBackStringArray(popupOptions, "Yellow");
                        popupOptions = pushBackStringArray(popupOptions, "Black");
	</onEnter>
</mediaDisplay>
</fontshadowcolor>
<subencoding>
    <mediaDisplay>
	<onEnter>
		popupHeader = "Choose Subtitle encoding";
			popupMessageSize = 0;
			popupMessages = "";
			popupOptionSize = 5;
			popupOptions = pushBackStringArray(popupOptions, "UTF8");
			popupOptions = pushBackStringArray(popupOptions, "Romania");
			popupOptions = pushBackStringArray(popupOptions, "Greek");
                        popupOptions = pushBackStringArray(popupOptions, "Chinese");
                        popupOptions = pushBackStringArray(popupOptions, "None");
	</onEnter>
</mediaDisplay>
</subencoding>
        <infoDisplay offsetXPC="0" offsetYPC="0" widthPC="100" heightPC="100">
<image redraw=yes offsetXPC=10 offsetYPC=45 widthPC=30 heightPC=5>
<script>
bar_bg;
</script>
</image>

<image redraw=yes offsetXPC=10 offsetYPC=45 heightPC=5>
<script>
bar_fg;
</script>
<widthPC>
<script>
(play_elapsed/play_total)*30;
</script>
</widthPC>
</image>
            <text valign=bottom align=center redraw="yes" offsetXPC="2" useBackgroundSurface="yes" lines=6>
                <script>tline1;</script>
                <fontFile>
                    <script>
                        fontname;
                    </script>
                </fontFile>
                <offsetYPC>
                    <script>
                        53 + fontoffset;
                    </script>
                </offsetYPC>
                <fontSize>
                    <script>
                        fontsize;
                    </script>
                </fontSize>
                <foregroundColor>
                    <script>
                        font_shadow_col;
                    </script>
                </foregroundColor>
                <backgroundColor>
                        -1:-1:-1;
                </backgroundColor>
                <widthPC>
                    <script>
                        97;
                    </script>
                </widthPC>
                <heightPC>
                    <script>
                        50;
                    </script>
                </heightPC>
            </text>
            <text valign=bottom align=center redraw="yes" offsetXPC="1.7" useBackgroundSurface="no" lines=6>
                <script>tline1;</script>
                <fontFile>
                    <script>
                        fontname;
                    </script>
                </fontFile>
                <offsetYPC>
                    <script>
                        52.7 + fontoffset;
                    </script>
                </offsetYPC>
                <fontSize>
                    <script>
                        fontsize;
                    </script>
                </fontSize>
                <foregroundColor>
                    <script>
                        fontcol;
                    </script>
                </foregroundColor>
                <backgroundColor>
                        -1:-1:-1;
                </backgroundColor>
                <widthPC>
                    <script>
                        97;
                    </script>
                </widthPC>
                <heightPC>
                    <script>
                        50;
                    </script>
                </heightPC>
            </text>
<text offsetXPC=5 offsetYPC=27 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=0:0:0 useBackgroundSurface=yes fontSize=12 widthPC=25>
<script>
subtitle;
</script>
</text>
<text offsetXPC=4.7 offsetYPC=26.7 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=255:255:255 useBackgroundSurface=no fontSize=12 widthPC=25>
<script>
subtitle;
</script>
</text>
<text offsetXPC=30 offsetYPC=11 heightPC=5 backgroundColor=-1:-1:-1 align=left foregroundColor=0:0:0 useBackgroundSurface=yes fontSize=12 widthPC=50>
<script>
movie_genre;
</script>
</text>
<text offsetXPC=29.7 offsetYPC=10.7 heightPC=5 backgroundColor=-1:-1:-1 align=left foregroundColor=255:255:255 useBackgroundSurface=no fontSize=12 widthPC=50>
<script>
movie_genre;
</script>
</text>
<text offsetXPC=30 offsetYPC=20 heightPC=5 backgroundColor=-1:-1:-1 align=left foregroundColor=0:0:0 useBackgroundSurface=yes fontSize=12 widthPC=15>
<script>
mov_rating;
</script>
</text>
<text offsetXPC=29.7 offsetYPC=19.7 heightPC=5 backgroundColor=-1:-1:-1 align=left foregroundColor=255:255:255 useBackgroundSurface=no fontSize=12 widthPC=15>
<script>
mov_rating;
</script>
</text>
            <text offsetXPC=10 offsetYPC=50 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=0:0:0 useBackgroundSurface=yes fontSize=18 widthPC=10>
<script>
    stream_elapsed;
</script>
</text>
<text offsetXPC=9.7 offsetYPC=49.7 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=255:255:255 useBackgroundSurface=no fontSize=18 widthPC=10>
<script>    
    stream_elapsed;
</script>
</text>
<text offsetXPC=32 offsetYPC=50 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=0:0:0 useBackgroundSurface=yes fontSize=18 widthPC=10>
<script>
    stream_total;
</script>
</text>
<text offsetXPC=31.7 offsetYPC=49.7 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=255:255:255 useBackgroundSurface=no fontSize=18 widthPC=10>
<script>    
    stream_total;
</script>
</text>
<text offsetXPC=5 offsetYPC=11 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=0:0:0 useBackgroundSurface=yes fontSize=12 widthPC=20>
<script>
info_delay;
</script>
</text>
<text offsetXPC=4.7 offsetYPC=10.7 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=255:255:255 useBackgroundSurface=no fontSize=12 widthPC=20>
<script>
info_delay;
</script>
</text>
<text offsetXPC=5 offsetYPC=5 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=0:0:0 align=left useBackgroundSurface=yes fontSize=12 widthPC=95>
<script>
info_title;
</script>
</text>
<text offsetXPC=4.7 offsetYPC=4.7 heightPC=5 backgroundColor=-1:-1:-1 foregroundColor=255:255:255 align=left useBackgroundSurface=no fontSize=12 widthPC=94.7>
<script>
info_title;
</script>
</text>
        </infoDisplay>
<onUserInput>
            userInput = currentUserInput(); 
            ret = "false";
            if (userInput == "display" || userInput == "DISPLAY"){
            show_time = 1 - show_time;
            stream_elapsed1 = "";
            redrawDisplay();
            ret = "true";
            }
            else if (userInput == "enter" || userInput == "ENTR" || userInput == "video_pause" || userInput == "video_play"){
            pause = 1 - pause;
            executeScript("pause");
            ret = "true";
            }
            else if (userInput == "video_completed" || userInput == "pagedown"){
            if (userInput == "video_completed"){
            if (nextplay == "yes") {
            deleteFile("/tmp/test.xml");
            executeScript("next_file");
            }
            else {
            postMessage("return");
            }
            }
            else {
            executeScript("next_file");
            }
            ret = "true";
            }
            else if (userInput == "video_stop"){
            playItemURL(-1, 1);
            postMessage("video_stop");
            deleteFile("/tmp/test.xml");
            writeStringToFile(url+".resume", play_elapsed);
            postMessage("return");
            ret = "true";
            }
            else if (userInput == "right" || userInput == "left" || userInput == "R" || userInput == "L"){
            if (play_status == 2)
            {
            setEnv("videoStatus", stream_progress);
            pause = 1;
            executeScript("pause");
            timePoint = doModalRss("/usr/local/etc/www/Jukebox/podcast_seekpopup.rss");
            if (timePoint != -1)
            {
            pause = 0;
            executeScript("pause");
            playAtTime(timePoint);
            play_elapsed = timePoint;
            tline1 = "";
            }
            }
            ret = "true";
            }
            else if (userInput == "up" || userInput == "U"){
            fontoffset = fontoffset - 0.5 ;
            ret = "true";
            }
            else if (userInput == "down" || userInput == "D"){
            fontoffset = 0.5 + fontoffset ;
            ret = "true";
            }
            else if (userInput == "one" || userInput == "1"){
            delay += 1 ;
            redrawDisplay();
            ret = "true";
            }
            else if (userInput == "three" || userInput == "3"){
            delay -= 1;
            redrawDisplay();
            ret = "true";
            }
            else if (userInput == "two" || userInput == "2"){
            delay = 0;
            redrawDisplay();
            ret = "true";
            }
            else if (userInput == "seven" || userInput == "7"){
            rss = "' . $this->script_url . '?set_font_type";
            ret = doModalRss(rss);
            if ( ret != null){
            fontname = ret;
            getURL("' . $this->script_url . '?SvCfg,font_type,"+ret);
            }
            redrawDisplay();
            ret = "true";
            }
            else if (userInput == "eight" || userInput == "8"){
		rss = "rss_file:///usr/local/etc/www/Jukebox/dynamicPopup.rss";
		ret_col = doModalRss(rss, "mediaDisplay", "fontcolor", 0);
		if (ret_col == "White") {
			fontcol = "255:255:255";}
		else if (ret_col == "Blue") {
			fontcol = "62:56:239";}
		else if (ret_col == "Yellow") {
			fontcol = "255:255:0";}
		if (ret_col != null) {
		getURL("' . $this->script_url . '?SvCfg,font_color,"+fontcol); }
            ret = "true";
            }
            else if (userInput == "nine" || userInput == "9"){
		rss = "rss_file:///usr/local/etc/www/Jukebox/dynamicPopup.rss";
		ret_col = doModalRss(rss, "mediaDisplay", "fontshadowcolor", 0);
		if (ret_col == "White") {
			font_shadow_col = "255:255:255";}
		else if (ret_col == "Blue") {
			font_shadow_col = "62:56:239";}
		else if (ret_col == "Yellow") {
			font_shadow_col = "255:255:0";}
                else if (ret_col == "Black") {
			font_shadow_col = "0:0:0";}
		if (ret_col != null) {
		getURL("' . $this->script_url . '?SvCfg,font_shadow_color,"+font_shadow_col); }
            ret = "true";
            }
            else if (userInput == "four"){
            set_size = doModalRss("http://127.0.0.1/Jukebox/srjg.php?sub_set_size,"+ fontsize);
            redrawDisplay();
            if (set_size != NULL){
            fontsize = set_size; }
            redrawDisplay();
            ret = "true";
            }
            else if (userInput == "five" || userInput == "5" || userInput == "option_red"){
            if (aspect_ratio1 == "$[PAN_SCAN_4_BY_3]")
            {
            setAspectRatio("$[LETTER_BOX_4_BY_3]");
            aspect_ratio1="$[LETTER_BOX_4_BY_3]";
            }
            else if (aspect_ratio1 == "$[LETTER_BOX_4_BY_3]")
            {
            setAspectRatio("$[WIDE_16_BY_9]");
            aspect_ratio1="$[WIDE_16_BY_9]";
            }
            else if (aspect_ratio1 == "$[WIDE_16_BY_9]")
            {
            setAspectRatio("$[WIDE_16_BY_10]");
            aspect_ratio1="$[WIDE_16_BY_10]";
            }
            else if (aspect_ratio1 == "$[WIDE_16_BY_10]") {
            setAspectRatio("$[PAN_SCAN_4_BY_3]");
            aspect_ratio1="$[PAN_SCAN_4_BY_3]";
            }
            ret = "true";
            }
            else if (userInput == "six" || userInput == "6"){
            pause = 1;
            executeScript("pause");
            sub_set = doModalRss("http://127.0.0.1/Jukebox/srjg.php?sub_sel,' . urlencode($file) . '");
            if ( sub_set != NULL ) {
            if ( sub_set == "sub_off"){
            writeStringToFile("/tmp/test.xml", "&lt;subtitrare&gt;off&lt;&#47;subtitrare&gt;");
            file = loadXMLFile("/tmp/test.xml");
            subt = 2 ;
            }
            else {
            file = loadXMLFile("/tmp/test.xml");
            if(readStringFromFile("/tmp/test.xml") != null){
            subt = 1;
            }
            first_run = "0";
            }	}
            pause = 0;
            executeScript("pause");
            redrawDisplay();
            ret = "true";
            }
            else if (userInput == "zero") {
            pause = 1;
            executeScript("pause");
            rss = "rss_file:///usr/local/etc/www/Jukebox/dynamicPopup.rss";
		ret_enc = doModalRss(rss, "mediaDisplay", "subencoding", 0);
		if (ret_enc == "UTF8") {
			encoding = "utf-8";}
		else if (ret_enc == "Romania") {
			encoding = "iso-8859-2";}
		else if (ret_enc == "Greek") {
			encoding = "GREEK";}
                else if (ret_enc == "Chinese") {
			encoding = "CHINESE";}
                else if (ret_enc == "None") {
			encoding = "none";}
		if (ret_enc != null) {
		getURL("' . $this->script_url . '?sub_encode,"+encoding);
                loadXMLFile("/tmp/test.xml"); }
                pause = 0;
            executeScript("pause");
            ret = "true";
            }
            ret;
</onUserInput>

    </mediaDisplay>
<menu>
	<mediaDisplay>
		<onEnter>
			popupHeader = "Edit menu";
			popupMessageSize = 1;
			popupMessages = getEnv("popup");
			popupOptionSize = 8;
                        if(getEnv("type") == "video"){
                        read = readStringFromFile(getEnv("edit_path")+".seen");
                        if(read != NULL) {
                        popupOptions = pushBackStringArray(popupOptions, "Mark as Unseen");
                        }
                        else {
                        popupOptions = pushBackStringArray(popupOptions, "Mark as Seen");
                        }
                        }
			popupOptions = pushBackStringArray(popupOptions, "Copy");
			popupOptions = pushBackStringArray(popupOptions, "Move");
                        popupOptions = pushBackStringArray(popupOptions, "Delete");
                        popupOptions = pushBackStringArray(popupOptions, "Rename");
                        if(getEnv("fav_env") == "yes"){
                        popupOptions = pushBackStringArray(popupOptions, "Remove Fav");
                        } else {
                        popupOptions = pushBackStringArray(popupOptions, "Add Fav"); }
                        unsetEnv("fav_env");
                        unsetEnv("edit_path");
                        unsetEnv("type");
		</onEnter>
	</mediaDisplay>
</menu>
<next_file>
playItemURL(-1, 1);
storagePath = "/tmp/video_list.dat";
idArray = readStringFromFile(storagePath);
number = 0;
querySymbols = "";
symbol = getStringArrayAt(idArray, number);
while (symbol != null) {
    symbol = getStringArrayAt(idArray, number);
    if ( symbol == url ) {
        comp = number + 1;
    }
    number = number + 1;
}
    if ( comp != null) {
        url = getStringArrayAt(idArray, comp);
        if ( url != null) {
        writeStringToFile("/tmp/nexturl", url);
        showIdle();
        dummy=getURL("'. $this->script_url . '?srtxml,url,nexturl");
        playItemURL(url, 0, "mediaDisplay", "previewWindow");
        file = loadXMLFile("/tmp/test.xml");
        mark_seen = 2;
        }
        else {
        postMessage("return");
        }
    }
    else {
        postMessage("return");
    }
</next_file>
<pause>
if (pause == 0) {
            postMessage("video_play");
            SetScreenSaverStatus("no");
            setRefreshTime(100);
            redrawDisplay(); }
            else {
            postMessage("video_pause");
            if(screensaver != "$[OFF]"){
            SetScreenSaverStatus("yes");
            }
            setRefreshTime(1000); }
</pause>
<channel>
        <title>video stream player</title>
    </channel>

</rss>';

